package com.aegean.MonitorExamSYS.conduction.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.conduction.business.ConductionBusiness;
import com.aegean.MonitorExamSYS.conduction.tools.TypeConvert;
import com.aegean.MonitorExaxSYS.model.ConductionValue;
import com.aegean.MonitorExaxSYS.model.ExamPosition;
import com.opensymphony.xwork2.ActionSupport;
@Controller("CRUDExamPosition")
@Scope("prototype")
public class CRUDExamPosition extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -449674130430351199L;
	@Resource
	ConductionBusiness business;
	private ConductionValue conduction;
	private ExamPosition examPosition;
	private String state;
	private boolean success;
	private String msg;
	private int[] examPosition_Ids;
	public int[] getExamPosition_Ids() {
		return examPosition_Ids;
	}
	public void setExamPosition_Ids(int[] examPosition_Ids) {
		this.examPosition_Ids = examPosition_Ids;
	}
	public ExamPosition getExamPosition() {
		return examPosition;
	}
	public void setExamPosition(ExamPosition examPosition) {
		this.examPosition = examPosition;
	}
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String add() throws Exception {
		examPosition.setExamPosition_State(TypeConvert.NameToNum(state));
		HttpSession session=ServletActionContext.getRequest().getSession();
		conduction=(ConductionValue)session.getAttribute("ConductionLogin");
		success=business.insertExamPosition(examPosition,conduction);
		if(success==true){
			msg="增加考场成功！";
		}else{
			msg="对不起，增加考场失败！";
		}
		return SUCCESS;
	}
	public String edit() throws Exception {
		examPosition.setExamPosition_State(TypeConvert.NameToNum(state));
		success=business.editExamPosition(examPosition,examPosition.getExamPosition_Id());
		return SUCCESS;
	}
	public String delete() throws Exception {
		success=business.deleteExamPositions(examPosition_Ids);
		return SUCCESS;
	}
}
